package com.tizona.entity;

import java.util.Calendar;
import java.util.Date;

public class Accumulator {

    Accumulator(String s, long l, Date date, Calendar calendar, boolean flag)
    {
        value = 0L;
        lastUpdate = null;
        model_time = null;
        oldValue = 0L;
        value = l;
        oldValue = l;
        exists = flag;
        undef = false;
        lastUpdate = date;
        model_time = calendar;
        name = s;
        changed = false;
    }

    public void add(long l)
    {
        value += l;
        lastUpdate = model_time.getTime();
        changed = true;
    }

    protected boolean existsInDatabase()
    {
        return exists;
    }

    public long get()
    {
        return value;
    }

    public Date getLastUpdate()
    {
        return new Date(lastUpdate.getTime());
    }

    public String getName()
    {
        return name;
    }

    protected boolean getUndefine()
    {
        return undef;
    }

    protected boolean hasChanged()
    {
        return changed;
    }

    public void set(long l)
    {
        value = l;
        lastUpdate = model_time.getTime();
        changed = true;
    }

    protected void setUndefine(boolean flag)
    {
        undef = flag;
    }

    private long value;
    private Date lastUpdate;
    private Calendar model_time;
    private long oldValue;
    private boolean exists;
    private boolean undef;
    private String name;
    private boolean changed;
}
